package com.hjl.controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
//控制器:IndexController
/*@RequestMapping("/user")*/
public class IndexController{

    private Logger logger = Logger.getLogger(IndexController.class);

    /**
     *  参数传递：View to Controller
     * @Param username
     */
    @RequestMapping(value = "/index",method = RequestMethod.GET,params = "username")
    public ModelAndView index(@RequestParam String username) {
        logger.info("hello，SpringMVC，" + username);
        ModelAndView mView = new ModelAndView();
        mView.addObject("username",username);
        mView.setViewName("index");
        return mView;
    }


/*    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest arg0,HttpServletResponse arg1) throws Exception {

        System.out.println("hello,SpringMVC!");
        return new ModelAndView("index");
    }*/
}

